// Domien Nowicki
#include "QtLineSprite.h"
#include <QPainter>

QtLineSprite::QtLineSprite(QtSprite *parent): QtSprite(parent), lineItem(0)
{
	lineItem = new QGraphicsLineItem(this);
}

QtLineSprite::~QtLineSprite()
{
}

void QtLineSprite::SetColor(const QColor& newColor)
{
	QPen pen = lineItem->pen();
	pen.setColor(newColor);
	lineItem->setPen(pen);
}

void QtLineSprite::SetLineWidth(unsigned int width)
{
	QPen pen = lineItem->pen();
	pen.setWidth(width);
	lineItem->setPen(pen);
}

void QtLineSprite::SetLine(const QPointF& begin, const QPointF& end)
{
	lineItem->setLine(QLineF(MapFromScene(begin), MapFromScene(end)));
}

QRectF QtLineSprite::boundingRect() const
{
	return lineItem->boundingRect();
}

QPainterPath QtLineSprite::shape() const
{
	return lineItem->shape();
}

void QtLineSprite::AlphaUpdated(qreal alpha)
{
	QPen pen = lineItem->pen();
	QColor color = pen.color();

	color.setAlpha(alpha*255);
	pen.setColor(color);
	lineItem->setPen(pen);
}


void QtLineSprite::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
}



